﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;

namespace CodeStash.Common.DataAccess.EntityFramework
{
    [DataContract]
    public partial class CodeSnippet
    {
        public CodeSnippet()
        {
            this.CodeTags = new List<CodeTag>();
            this.CodeSnippetForumMessages = new List<CodeSnippetForumMessage>();
        }

        public CodeSnippet(string actualCode, int codeCategoryId, string description,
            string title,Nullable<int> groupId,int languageId,Guid aspNetMembershipUserId,
            Visibility visibility, int views, int rating, int totalRatings, DateTime modifiedDate)
        {
            this.ActualCode= actualCode; 
            this.CodeCategoryId= codeCategoryId;
            this.Description = description;
            this.Title = title;
            this.GroupId= groupId;
            this.LanguageId= languageId;
            this.AspNetMembershipUserId= aspNetMembershipUserId;
            this.Visibility1 = visibility;
            this.CodeTags = new List<CodeTag>();
            this.Views = views;
            this.Rating = rating;
            this.TotalRatings = totalRatings;
            this.ModifiedDate = modifiedDate;
        }


        [Key]
        [DataMember]
        public int CodeSnippetId { get; set; }

        [DataMember]
        public string ActualCode { get; set; }

        [ForeignKey("CodeCategoryId")]
        [DataMember]
        public int CodeCategoryId { get; set; }

        [DataMember]
        public string Description { get; set; }

        [DataMember]
        public string Title { get; set; }

        [ForeignKey("GroupId")]
        [DataMember]
        public Nullable<int> GroupId { get; set; }

        [ForeignKey("LanguageId")]
        [DataMember]
        public int LanguageId { get; set; }

        [DataMember]
        public Guid AspNetMembershipUserId { get; set; }

        [ForeignKey("VisibilityId")]
        [DataMember]
        public int Visibility { get; set; }

        [DataMember]
        public virtual CodeCategory CodeCategory { get; set; }

        [DataMember]
        public virtual Visibility Visibility1 { get; set; }

        [DataMember]
        public virtual Grouping Grouping { get; set; }

        [DataMember]
        public virtual Language Language { get; set; }

        [DataMember]
        public virtual List<CodeTag> CodeTags { get; set; }

        [DataMember]
        public int Views { get; set; }

        [DataMember]
        public int Rating { get; set; }

        [DataMember]
        public int TotalRatings { get; set; }

        [DataMember]
        public DateTime ModifiedDate { get; set; }

        [DataMember]
        public List<CodeSnippetForumMessage> CodeSnippetForumMessages { get; set; }
    }
}